package com.music.service.playlists.beans;

import java.sql.Date;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import com.music.service.playlists.constants.PlaylistState;
import com.music.service.songs.beans.Song;

public class Playlist {
	private Long mPlaylistId;
	private String mPlaylistName;
	private Long mOwnerId;
	private PlaylistState mPlaylistState;
	private Date mCreationDate;
	private Date mLastUpdateDate;
	private Date mLastAccessedDate;
	private boolean mRepeat;
	private boolean mShuffle;
	private Long mLastAddedSongId;
	private Map<Long,Song> mSongsMap;
	
	
	public Playlist(){
		mSongsMap = new HashMap<Long, Song>();
		mRepeat = false;
		mShuffle = false;
	}
	/**
	 * @return the playlistId
	 */
	public Long getPlaylistId() {
		return mPlaylistId;
	}

	/**
	 * @param pPlaylistId
	 *            the playlistId to set
	 */
	public void setPlaylistId(Long pPlaylistId) {
		mPlaylistId = pPlaylistId;
	}

	/**
	 * @return the playlistName
	 */
	public String getPlaylistName() {
		return mPlaylistName;
	}

	/**
	 * @param pPlaylistName
	 *            the playlistName to set
	 */
	public void setPlaylistName(String pPlaylistName) {
		mPlaylistName = pPlaylistName;
	}

	/**
	 * @return the ownerId
	 */
	public Long getOwnerId() {
		return mOwnerId;
	}

	/**
	 * @param pOwnerId
	 *            the ownerId to set
	 */
	public void setOwnerId(Long pOwnerId) {
		mOwnerId = pOwnerId;
	}

	/**
	 * @return the playlistState
	 */
	public PlaylistState getPlaylistState() {
		return mPlaylistState;
	}

	/**
	 * @param pPlaylistState
	 *            the playlistState to set
	 */
	public void setPlaylistState(PlaylistState pPlaylistState) {
		mPlaylistState = pPlaylistState;
	}

	/**
	 * @return the creationDate
	 */
	public Date getCreationDate() {
		return mCreationDate;
	}

	/**
	 * @param pCreationDate the creationDate to set
	 */
	public void setCreationDate(Date pCreationDate) {
		mCreationDate = pCreationDate;
	}

	/**
	 * @return the lastAddedSongId
	 */
	public Long getLastAddedSongId() {
		return mLastAddedSongId;
	}

	/**
	 * @param pLastAddedSongId the lastAddedSongId to set
	 */
	public void setLastAddedSongId(Long pLastAddedSongId) {
		mLastAddedSongId = pLastAddedSongId;
	}

	/**
	 * @return the lastUpdateDate
	 */
	public Date getLastUpdateDate() {
		return mLastUpdateDate;
	}

	/**
	 * @param pLastUpdateDate the lastUpdateDate to set
	 */
	public void setLastUpdateDate(Date pLastUpdateDate) {
		mLastUpdateDate = pLastUpdateDate;
	}

	
	
	/**
	 * @return the songsMap
	 */
	public Map<Long, Song> getSongsMap() {
		return mSongsMap;
	}

	/**
	 * @param pSongsMap the songsMap to set
	 */
	public void setSongsMap(Map<Long, Song> pSongsMap) {
		mSongsMap = pSongsMap;
	}

	public void addSong(Song pSong){
		if(getSongsMap() == null){
			setSongsMap(new HashMap<Long,Song>());
		}
		getSongsMap().put(pSong.getSongId(), pSong);
	}
	
	public Collection<Song> getSongs(){
		if(getSongsMap() != null){
			return getSongsMap().values();
		}
		//return empty array.
		return new ArrayList<Song>();
	}

	public Collection<Long> getSongIds(){
		if(getSongsMap() != null){
			return getSongsMap().keySet();
		}
		//return empty set.
		return new HashSet<Long>(); 
	}
	/**
	 * @return the lastAccessedDate
	 */
	public Date getLastAccessedDate() {
		return mLastAccessedDate;
	}
	/**
	 * @param pLastAccessedDate the lastAccessedDate to set
	 */
	public void setLastAccessedDate(Date pLastAccessedDate) {
		mLastAccessedDate = pLastAccessedDate;
	}
	/**
	 * @return the repeat
	 */
	public boolean isRepeat() {
		return mRepeat;
	}
	/**
	 * @param pRepeat the repeat to set
	 */
	public void setRepeat(boolean pRepeat) {
		mRepeat = pRepeat;
	}
	/**
	 * @return the shuffle
	 */
	public boolean isShuffle() {
		return mShuffle;
	}
	/**
	 * @param pShuffle the shuffle to set
	 */
	public void setShuffle(boolean pShuffle) {
		mShuffle = pShuffle;
	}
	
	
}
